// 权限点管理
var Permission = Ext.data.Record.create([{
	name : 'id',
	mapping : 'id',
	type : 'int'
}, {
	name : 'resId',
	mapping : 'resId',
	type : 'string'
}, {
	name : 'resName',
	mapping : 'resName',
	type : 'string'
}, {
	name : 'resType',
	mapping : 'resType',
	type : 'string'
}, {
	name : 'resUrl',
	mapping : 'resUrl',
	type : 'string'
},{
	name : '备注',
	mapping : 'remark',
	type : 'string'
}]);

var sm = new Ext.grid.RowNumberer();
var cm_permission = new Ext.grid.ColumnModel([
	new Ext.grid.RowNumberer({header : '序号', width : 40, dataIndex: 'id'}),
	{id: 'resName',header: "权限点名称", width: 80, sortable: true, dataIndex: 'resName'},
    {id: 'resUrl',header: "访问 URL", width: 80, sortable: true, dataIndex: 'resUrl'},
    {id: 'resId',header: "权限引用资源ID", width: 80, sortable: true, dataIndex: 'resId'},
    {id: 'resType',header: "权限类型", width: 80, sortable: true, dataIndex: 'resType'},
    {id: 'remark',header: "备注", width: 80, sortable: true, dataIndex: 'remark'}
]);

cm_permission.defaultSortable = false;

var btn_search_permission = new Ext.Button({
	text : '查询',
	iconCls : 'icon-search',
	handler : function() {
		grid_permission.render();
		ds_permission.load();
	}
});

var ds_permission = new Ext.data.Store({
	proxy : new Ext.data.HttpProxy({
		url : '/supervise/sys/permission/findAllPermission.action'
	}),
//	autoLoad: true,
	reader : new Ext.data.JsonReader({
		root : 'root',
		successProperty :'success'
	}, [{
		name : 'id',
		type : 'int'
	}, {
		name : 'resId',
		type : 'string'
	}, {
		name : 'resName',
		type : 'string'
	},{
		name : 'resType',
		type : 'string'
	},{
		name : 'resUrl',
		type : 'string'
	},{
		name : 'remark',
		type : 'string'
	}])
});

var grid_permission = new Ext.grid.GridPanel({
	title : '权限点查询',
	iconCls : 'icon-grid',
	loadMask : {
		msg : '数据加载中...'
	},
	viewConfig: { forceFit:true},
	region : 'center',
	cm : cm_permission,
	sm : new Ext.grid.RowSelectionModel({singleSelect:true}),
	store : ds_permission,
	autoExpandColumn : 'remark', 
	bbar : new Ext.PagingToolbar({
						pageSize : 200,
						store : ds_permission,
						displayInfo : false,
						displayMsg : '第 {0} - {1} 条  共 {2} 条',
						refreshText:"刷新",
						emptyMsg : "没有记录"
					}),
	listeners : {
				'render' : function(e) {
					ds_permission.load();
				}
			}
});

var p_permission = {
	id : 'permission-panel',
	border : false,
	layout : 'border',
	items : [grid_permission]
};